﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace 工业设备监控系统.Models
{
    public class Device
    {
        public int Id { get; set; }
        public string Name { get; set; } = string.Empty;
        public string Description { get; set; } = string.Empty;

        // 通信类型：TCP / RTU / Simulation
        public string CommunicationType { get; set; } = "Simulation";

        // TCP 用
        public string IpAddress { get; set; } = "127.0.0.1";

        public int Port { get; set; } = 502;

        // 串口用
        public string PortName { get; set; } = "COM1";

        public int BaudRate { get; set; } = 9600;

        // 运行状态
        public string Status { get; set; } = "离线"; // 运行、停止、故障

        public bool IsEnabled { get; set; } = true;
        public DateTime LastHeartbeat { get; set; } = DateTime.Now;

        // 导航属性：一个设备有多个寄存器
        public virtual ICollection<Register> Registers { get; set; } = new HashSet<Register>();
    }
}